home *** CD-ROM | disk | FTP | other *** search
/ HAKERIS 11 / HAKERIS 11.ISO / linux / system / LinuxConsole 0.4 / linuxconsole0.4install-en.iso / guile0.4.lcm / share / guile / 1.6.0 / srfi / srfi-13.scm < prev    next >
Encoding:
Text File  |  2004-01-06  |  5.2 KB  |  190 lines

  1. ;;; srfi-13.scm --- String Library
  2.  
  3. ;;     Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  4. ;;
  5. ;; This program is free software; you can redistribute it and/or
  6. ;; modify it under the terms of the GNU General Public License as
  7. ;; published by the Free Software Foundation; either version 2, or
  8. ;; (at your option) any later version.
  9. ;;
  10. ;; This program is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ;; General Public License for more details.
  14. ;;
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with this software; see the file COPYING.  If not, write to
  17. ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  18. ;; Boston, MA 02111-1307 USA
  19. ;;
  20. ;; As a special exception, the Free Software Foundation gives permission
  21. ;; for additional uses of the text contained in its release of GUILE.
  22. ;;
  23. ;; The exception is that, if you link the GUILE library with other files
  24. ;; to produce an executable, this does not by itself cause the
  25. ;; resulting executable to be covered by the GNU General Public License.
  26. ;; Your use of that executable is in no way restricted on account of
  27. ;; linking the GUILE library code into it.
  28. ;;
  29. ;; This exception does not however invalidate any other reasons why
  30. ;; the executable file might be covered by the GNU General Public License.
  31. ;;
  32. ;; This exception applies only to the code released by the
  33. ;; Free Software Foundation under the name GUILE.  If you copy
  34. ;; code from other Free Software Foundation releases into a copy of
  35. ;; GUILE, as the General Public License permits, the exception does
  36. ;; not apply to the code that you add in this way.  To avoid misleading
  37. ;; anyone as to the status of such modified files, you must delete
  38. ;; this exception notice from them.
  39. ;;
  40. ;; If you write modifications of your own for GUILE, it is your choice
  41. ;; whether to permit this exception to apply to your modifications.
  42. ;; If you do not wish that, delete this exception notice.
  43.  
  44. ;;; Commentary:
  45.  
  46. ;; This module is fully documented in the Guile Reference Manual.
  47.  
  48. ;;; Code:
  49.  
  50. (define-module (srfi srfi-13))
  51.  
  52. (begin-deprecated
  53.  ;; Prevent `export' from re-exporting core bindings.  This behaviour
  54.  ;; of `export' is deprecated and will disappear in one of the next
  55.  ;; releases.
  56.  (define string->list #f)
  57.  (define string-copy #f)
  58.  (define string-fill! #f)
  59.  (define string-index #f)
  60.  (define string-upcase #f)
  61.  (define string-upcase! #f)
  62.  (define string-downcase #f)
  63.  (define string-downcase! #f))
  64.  
  65. (export
  66. ;;; Predicates
  67.  ;; string? string-null?       <= in the core
  68.  string-any string-every
  69.  
  70. ;;; Constructors
  71.  ;; make-string string         <= in the core
  72.  string-tabulate
  73.  
  74. ;;; List/string conversion
  75.  string->list
  76.  ;; list->string               <= in the core
  77.  reverse-list->string
  78.  string-join
  79.  
  80. ;;; Selection
  81.  ;; string-length string-ref   <= in the core
  82.  string-copy
  83.  substring/shared
  84.  string-copy!
  85.  string-take string-take-right
  86.  string-drop string-drop-right
  87.  string-pad string-pad-right
  88.  string-trim string-trim-right
  89.  string-trim-both
  90.  
  91. ;;; Modification
  92.  ;; string-set!                <= in the core
  93.  string-fill!
  94.  
  95. ;;; Comparison
  96.  string-compare string-compare-ci
  97.  string= string<>
  98.  string< string>
  99.  string<= string>=
  100.  string-ci= string-ci<>
  101.  string-ci< string-ci>
  102.  string-ci<= string-ci>=
  103.  string-hash string-hash-ci
  104.  
  105. ;;; Prefixes/Suffixes
  106.  string-prefix-length
  107.  string-prefix-length-ci
  108.  string-suffix-length
  109.  string-suffix-length-ci
  110.  string-prefix?
  111.  string-prefix-ci?
  112.  string-suffix?
  113.  string-suffix-ci?
  114.  
  115. ;;; Searching
  116.  string-index string-index-right
  117.  string-skip string-skip-right
  118.  string-count
  119.  string-contains string-contains-ci
  120.  
  121. ;;; Alphabetic case mapping
  122.  
  123.  string-upcase string-upcase!
  124.  string-downcase string-downcase!
  125.  string-titlecase string-titlecase!
  126.  
  127. ;;; Reverse/Append
  128.  string-reverse string-reverse!
  129.  ;; string-append                    <= in the core
  130.  string-append/shared
  131.  string-concatenate
  132.  string-concatenate-reverse
  133.  string-concatenate/shared
  134.  string-concatenate-reverse/shared
  135.  
  136. ;;; Fold/Unfold/Map
  137.  string-map string-map!
  138.  string-fold
  139.  string-fold-right
  140.  string-unfold
  141.  string-unfold-right
  142.  string-for-each
  143.  string-for-each-index
  144.  
  145. ;;; Replicate/Rotate
  146.  xsubstring string-xcopy!
  147.  
  148. ;;; Miscellaneous
  149.  string-replace
  150.  string-tokenize
  151.  
  152. ;;; Filtering/Deleting
  153.  string-filter
  154.  string-delete
  155.  )
  156.  
  157. (cond-expand-provide (current-module) '(srfi-13))
  158.  
  159. (load-extension "libguile-srfi-srfi-13-14-v-1" "scm_init_srfi_13")
  160.  
  161. (define string-hash
  162.   (lambda (s . rest)
  163.     (let ((bound (if (pair? rest)
  164.              (or (car rest)
  165.              871)
  166.              871))
  167.       (start (if (and (pair? rest) (pair? (cdr rest)))
  168.              (cadr rest)
  169.              0))
  170.       (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest)))
  171.            (caddr rest)
  172.            (string-length s))))
  173.       (hash (substring/shared s start end) bound))))
  174.  
  175. (define string-hash-ci
  176.   (lambda (s . rest)
  177.     (let ((bound (if (pair? rest)
  178.              (or (car rest)
  179.              871)
  180.              871))
  181.       (start (if (and (pair? rest) (pair? (cdr rest)))
  182.              (cadr rest)
  183.              0))
  184.       (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest)))
  185.            (caddr rest)
  186.            (string-length s))))
  187.       (hash (string-upcase (substring/shared s start end)) bound))))
  188.  
  189. ;;; srfi-13.scm ends here
  190.